<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/incube-app.tld" prefix="app" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%!
	int id = 1;
	int iteracion = 1;
	int cantpordiv = 0; // Se inicializa en initVars

	public String initVars(String cant){
		id = 1;
		cantpordiv = Integer.parseInt(cant);
		iteracion = 0;
		return "";
	}
	
	public String getNextID(){
		return Integer.toString(id++);
	}
	public String getStyle(){
		if((id - 1) > 1)
			return "style=\"display:none\"";
		return "";
	}
	public String incrementarIterador(){
		iteracion += 1;
		return "";
	}

	public String getHeaderDIV(){
		if( (iteracion % cantpordiv) == 0){
			return "<div id=\"p" + getNextID()+ "\" " + getStyle() + ">";
		}
		return "";
	}
		
	public String getFooterDIV(){
		if(((iteracion + 1) % cantpordiv) == 0){
				return "</div>";
		}
		return "";
	}
%>
<%=initVars("10")%>
<script language="javascript">
	showLabel("ver")

    function validar(){
        var valido = false;
        for(i=0;i<document.forms[0].length;i++){
            if(document.forms[0][i].checked){
                valido = true;
                break;
            }
        }
        return valido;
    }

</script>	
<table border="0" cellpadding="5" cellspacing="0" height="100%" style="font-family:arial;font-size:8pt" width="100%">
<tr>
	<td valign="top">
		<form action="/adm/verUsuario.do" onsubmit="return false;">
		<p align="center">
			<input type="button" value="Ver Detalles" onclick="if(validar()){document.forms[0].action='/adm/verUsuario.do';document.forms[0].submit()}" style="height:18pt;width:20%;background-color:rgb(204, 204, 204);color:rgb(0, 0, 0);font-family: arial; font-size: 9pt;font-weight:normal">
			<input type="button" value="Editar" onclick="if(validar()){document.forms[0].action='/adm/editarUsuario.do';document.forms[0].submit()}" style="height:18pt;width:20%;background-color:rgb(204, 204, 204);color:rgb(0, 0, 0);font-family: arial; font-size: 9pt;font-weight:normal">
			<input type="button" value="Eliminar" onclick="if(validar()){document.forms[0].action='/adm/eliminarUsuario.do';document.forms[0].submit()}" style="height:18pt;width:20%;background-color:rgb(204, 204, 204);color:rgb(0, 0, 0);font-family: arial; font-size: 9pt;font-weight:normal">
			<input type="reset" value="Borrar" style="height:18pt;width:20%;background-color:rgb(204, 204, 204);color:rgb(0, 0, 0);font-family: arial; font-size: 9pt;font-weight:normal">
		</p>
		<br>
		<table border="0" cellpadding="5" cellspacing="0" width="100%" style="font-family:arial;font-size:8pt">
			<tr>
				<th width="5%" style="background-color:#3399ca;color:#ffffff">
					&nbsp;
				</th>
				<th width="55%" style="background-color:#3399ca;color:#ffffff">
					Empresa
				</th>
				<th width="30%" style="background-color:#3399ca;color:#ffffff">
					Usuario
				</th>
				<th width="10%" style="background-color:#3399ca;color:#ffffff">
					Nivel
				</th>
			</tr>
		</table>
		
		<logic:iterate id="usuario" name="usuarios" type="org.fiel.domain.User">
			<%=getHeaderDIV()%>
			<table border="1" cellpadding="2" cellspacing="0" width="100%" style="font-family:arial;font-size:8pt;border-top:0px none #cccccc;border-bottom:1px solid #cccccc">
				<tr>
					<td width="5%">
						<input type="radio" name="id" value="<bean:write name="usuario" property="identint"/>">
					</td>
					<td width="55%">
						&nbsp;<bean:write name="usuario" property="empresa"/>
					</td>
					<td width="30%">
						&nbsp;<bean:write name="usuario" property="id"/>
					</td>
					<td width="10%">
						&nbsp;<bean:write name="usuario" property="nivel"/>
					</td>
				</tr>
			</table>
			<%=getFooterDIV()%>
			<%=incrementarIterador()%>
		</logic:iterate>
		<%
			if ((iteracion % cantpordiv) != 0){
				out.println("</div>");
			}
		%>
		</form>
	</td>
	<td width="5%" valign="bottom">
		<a href="javascript:scrollUp()"><img border="0" src="images/scrollup.gif"></a>
		<a href="javascript:scrollDown()"><img border="0" src="images/scrolldown.gif"></a>
	</td>
</tr>
</table>
